package com.powernode.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.shop.domain.SysUser;
import com.powernode.shop.mapper.SysUserMapper;
import com.powernode.shop.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author ZHAOZHENYU
* @since 2022/10/10
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService{

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public Page<SysUser> getPage(Page<SysUser> page, SysUser sysUser) {
        String username = sysUser.getUsername();
        // like可传入条件是否执行
        return sysUserMapper.selectPage(page,new LambdaQueryWrapper<SysUser>()
        .like(StringUtils.hasText(username),SysUser::getUsername,username));
    }

}
